package prac;

import java.util.*;
import java.util.stream.Collectors;

public class Main1 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 while 处理多个 case
        int a = in.nextInt();
        List<Record> records=new ArrayList<>();
        Record record=null;
        for(int i=1;i<=a;i++){
            //计算当前值
           String sr=in.next();
           String[] str=  sr.split(",");
            record=new Record();
            record.setId(str[0]);
            record.setDktime(Integer.valueOf(str[1]));
            record.setDkjl(Integer.valueOf(str[2]));
            record.setSj(str[3]);
            record.setZc(str[4]);
            record.setSort(i);
            record.setSr(sr);
            records.add(record);
        }
        //按工号分组
        Map<String,List<Record>> stringListMap=new HashMap<>();

        for(Record record1:records){
            if(!stringListMap.containsKey(record1.id)){
                stringListMap.put(record1.id,new ArrayList<>());
            }
            stringListMap.get(record1.id).add(record1);
        }
       Set<Record> errorRe=new HashSet<>();//记录异常打卡
        for(String key:stringListMap.keySet()){
            List<Record> records1=stringListMap.get(key);
            records1.sort((o1,o2)->{return o1.dktime-o2.dktime;});
            Record last=null;
            for(Record record1:records1){
                if(!record1.sj.equals(record1.getZc())){
                    errorRe.add(record1);
                }if(last!=null){
                    if(Math.abs(record1.dktime-last.dktime)<60&&Math.abs(record1.dkjl- last.dkjl)>5){
                        errorRe.add(record1);
                        errorRe.add(last);
                    }
                }
                last= record1;
            }
        }
        if(errorRe.isEmpty()){
            System.out.println("null");
        } else{
          List<String> errorReList=errorRe.stream().sorted().map(Record::getSr).collect(Collectors.toList());
        String s=  String.join(";",errorReList);
            System.out.println(s);
        }

    }

    public static class Record implements Comparable<Record>{
        private String id;
        private int dktime;
        private int dkjl;
        private String sj;
        private String zc;
        private int sort;
        private String sr;
        public Record() {
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public int getSort() {
            return sort;
        }

        public void setSort(int sort) {
            this.sort = sort;
        }

        public String getZc() {
            return zc;
        }

        public void setZc(String zc) {
            this.zc = zc;
        }

        public String getSj() {
            return sj;
        }

        public void setSj(String sj) {
            this.sj = sj;
        }

        public int getDkjl() {
            return dkjl;
        }

        public void setDkjl(int dkjl) {
            this.dkjl = dkjl;
        }

        public int getDktime() {
            return dktime;
        }

        public void setDktime(int dktime) {
            this.dktime = dktime;
        }

        public String getSr() {
            return sr;
        }

        public void setSr(String sr) {
            this.sr = sr;
        }

        @Override
        public int compareTo(Record o) {
            return this.sort-o.sort;
        }
    }
}
